#!/usr/bin/python

from string import Template


s = Template('$who likes $what')


#
#   substitute use named parameters 
#
print s.substitute(who='tim', what='kung pao')

#
#   substitute use dictionary
#   double $$ escapes 
#
d = dict(who='tim')
print Template('Give $who $$100').substitute(d)

#
#   tolerate missing parameter with safe substitute
#
print Template('$who likes $what').safe_substitute(d)

